package com.sub.spark.streaming.instance;

import org.apache.spark.SparkConf;
import org.apache.spark.streaming.Duration;
import org.apache.spark.streaming.api.java.JavaReceiverInputDStream;
import org.apache.spark.streaming.api.java.JavaStreamingContext;

/**
 * @ClassName SparkStreamingInstance
 * @Description: TODO
 * @Author Submerge.
 * @Since 2025/5/25 22:50
 * @Version 1.0
 */

public class SparkStreamingInstance {

    public static void main(String[] args) throws InterruptedException {

        SparkConf sparkConf = new SparkConf().setAppName("sub-spark-streaming").setMaster("local[2]");
        JavaStreamingContext jsc = new JavaStreamingContext(sparkConf, new Duration(10*1000));


        JavaReceiverInputDStream<String> localhost = jsc.socketTextStream("localhost", 1234);

        localhost.print();


        jsc.start();
        jsc.awaitTermination();







        jsc.stop();




    }
}
